<style>
    #febs-apex-line .layui-card-header {
        font-weight: 600;
    }
</style>
<div class="layui-fluid layui-anim febs-anim" id="febs-apex-line" lay-title="线性图表">
    <div class="layui-row layui-col-space8 febs-container">
        <div class="layui-col-md6 layui-col-sm6 layui-col-xs12">


            <div class="layui-card">
                <div class="layui-card-header">表2-1  放大电路的静态工作点（Uces=1.2V）</div>
                <div class="layui-card-body">
                    <span style="color: red">*提示：双击单元格即可编辑输入</span>
                    <table lay-filter="test2_static" id="test2_static"></table>
                </div>
            </div>

            <div class="layui-card">
                <div class="layui-card-header">放大电路的放大倍数</div>
                <div class="layui-card-body">
                    <div id="main" style="width: 600px;height: 400px;"></div>
                </div>
            </div>
        </div>

    </div>
</div>
<script data-th-src="@{febs/lay/extends/echarts.min.js}"></script>
<script data-th-src="@{febs/lay/data/dataSeries.js}"></script>
<script data-th-inline="javascript" type="text/javascript">
    layui.use(['apexcharts','table', 'febs'], function () {
        var febs = layui.febs;
        var $ = layui.jquery;
        var table = layui.table;

        //执行渲染
        table.render({
            elem: '#test2_static', //指定原始表格元素选择器（推荐id选择器）
            url: ctx + 'test2Static/listPage',
            width:'1000',
            cols: [
                [
                {field: 'testCondition', title: '测试条件', minWidth: 100},
                {field: 'ib', title: '测量值ib',edit:true},
                {field: 'ic', title: '测量值ic',edit:true},
                {field: 'ub', title: '测量值ub',edit:true},
                {field: 'ue', title: '测量值ue',edit:true},
                {field: 'uc', title: '测量值uc',edit:true},
                {field: 'bb', title: '测量值bb',edit:true},
                {field: 'ube', title: '计算值ube',edit:true},
                {field: 'uce', title: '计算值uce',edit:true},
                {field: 'bb2', title: '计算值bb2',edit:true}
            ]
            ]
        });











        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('main'));
        function func(x) {
            x /= 10;
            return Math.sin(x) * Math.cos(x * 2 + 1) * Math.sin(x * 3 + 2) * 50;
        }

        function generateData() {
            let data = [];
            for (let i = 0; i <= 200; i += 0.1) {
                data.push([i, func(i)]);
            }

            console.log(data);

            return data;
        }

        var option = {
            animation: false,
            tooltip : {
                trigger: 'axis',
                axisPointer: {
                    type: 'cross',
                    label: {
                        backgroundColor: '#6a7985'
                    }
                }
            },
            grid: {
                top: 40,
                left: 50,
                right: 40,
                bottom: 50
            },
            xAxis: {
                name: 'x',
                minorTick: {
                    show: true
                },
                splitLine: {
                    lineStyle: {
                        color: '#999'
                    }
                },
                minorSplitLine: {
                    show: true,
                    lineStyle: {
                        color: '#ddd'
                    }
                }
            },
            yAxis: {
                name: 'y',
                min: -100,
                max: 100,
                minorTick: {
                    show: true
                },
                splitLine: {
                    lineStyle: {
                        color: '#999'
                    }
                },
                minorSplitLine: {
                    show: true,
                    lineStyle: {
                        color: '#ddd'
                    }
                }
            },
            dataZoom: [{
                show: true,
                type: 'inside',
                filterMode: 'none',
                xAxisIndex: [0],
                startValue: -20,
                endValue: 20
            }, {
                show: true,
                type: 'inside',
                filterMode: 'none',
                yAxisIndex: [0],
                startValue: -20,
                endValue: 20
            }],
            series: [
                {
                    type: 'line',
                    showSymbol: false,
                    clip: true,
                    data: generateData()
                }
            ]
        };
        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
        var interval = setInterval(function () {
            var urlHash = window.location.hash;
            if (urlHash.indexOf('apex/line') !== -1) {
                getNewSeries(lastDate, {
                    min: 10,
                    max: 90
                });
                realTimeChart.updateSeries([{
                    data: data
                }]);
            }
        }, 1000);

        febs.routeLeave(function (route, nextPath, next) {
            clearInterval(interval);
            next();
        })
    });
</script>